<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FSF.qsortex</title>
<meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../styles/styles.css">
<script language="javascript" src='../links.js' type="text/javascript"></script>
</head>
<body>

<h1>qsortex</h1>
<div class=navbar>
<a href="../index.html">main</a> |
<a href="index.html">FarStandardFunctions</a>
</div>

<div class=shortdescr>
The <dfn>FSF.qsortex</dfn> function allows to sort an array of any
type of data using the QuickSort algorithm. Unlike the <a href="qsort.html">qsort</a>
function, it allows to pass user-defined data to the compare function.
</div>

<pre class=syntax>
void WINAPI qsortex(
  void *Base,
  size_t NElem,
  size_t Width,
  int (<b>__cdecl</b> *fcmp)(const void *, const void *, void *),
  void *User
);
</pre>

<h3>Parameters</h3>
<div class=descr>
  <div class=dfn>Base</div>
  <div class=dfndescr>Start of target array.
  </div>

  <div class=dfn>NElem</div>
  <div class=dfndescr>Array size in elements.
  </div>

  <div class=dfn>Width</div>
  <div class=dfndescr>The size of each element in bytes.
  </div>

  <div class=dfn>fcmp</div>
  <div class=dfndescr>
  User-defined comparison function that must be declared with __cdecl - C-style
  calling convention. This function takes three arguments - <em>elem1</em>,
  <em>elem2</em> (the pointers to the array of elements) and <em>user</em>
  (user-defined data passed in the <em>User</em> argument to the <dfn>qsortex</dfn> function).
  <em>fcmp</em> function must compare <em>elem1</em> and <em>elem2</em> elements
  and return an integer value:
  <table border=0>
   <tr><td>*elem1 &lt; *elem2</td><td>- fcmp returns value < 0</td></tr>
   <tr><td>*elem1 == *elem2</td><td>- fcmp returns value == 0</td></tr>
   <tr><td>*elem1  &gt; *elem2</td><td>- fcmp returns value > 0</td></tr>
  </table>
  </div>

  <div class=dfn>User</div>
  <div class=dfndescr>User-defined data passed as the third parameter to the comparison function.
  </div>

</div>

<h3>Return value</h3>
<div class=descr>
None.
</div>

<h3>Remarks</h3>
<div class=descr>
The sort implemented by the <a href="qsort.html">qsort</a> and qsortex
functions is not stable. In other words, the order for the elements that
are equal according to the compare function is not defined. The order
can change when the array is sorted repeatedly.
</div>


<div class=see>See also:</div><div class=seecont>
<a href="bsearch.html">FSF.bsearch</a>,
<a href="qsort.html">FSF.qsort</a>
</div>

</body>
</html>
